gtk-demo: Improve an error message
authorMatthias Clasen <mclasen@redhat.com>
Sat, 8 Aug 2020 16:51:31 +0000 (12:51 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 8 Aug 2020 17:56:17 +0000 (13:56 -0400)
Be more helpful when we can't do syntax highlighting.

demos/gtk-demo/main.c

index b14e3b09090c52aa8b4222630c10f9412ceee4e1..d3f65220d08224c88fcc2af6c7600cc5f2edb901 100644 (file)
@@ -239,7 +239,6 @@ fontify_text (const char *format,
               const char *text)
 {
   GSubprocess *subprocess;
-  static gboolean warned = FALSE;
   GBytes *stdin_buf;
   GBytes *stdout_buf = NULL;
   GBytes *stderr_buf = NULL;
@@ -259,11 +258,19 @@ fontify_text (const char *format,
 
   if (!subprocess)
     {
-      if (!warned)
+      if (g_error_matches (error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT))
         {
-          g_warning ("%s", error->message);
-          warned = TRUE;
+          static gboolean warned = FALSE;
+
+          if (!warned)
+            {
+              warned = TRUE;
+              g_message ("For syntax highlighting, install the “highlight” program");
+            }
         }
+      else
+        g_warning ("%s", error->message);
+
       g_clear_error (&error);
 
       return NULL;